/******************************************************************************
*
* This file is part of FreeTrack (http://code.google.com/p/qtfreetrack).
* BY Willy Gardiol (willy@gardiol.org)
*
* FreeTrack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FreeTrack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar.  If not, see <http://www.gnu.org/licenses/>
*
******************************************************************************/

#ifndef FILENAVIGATOR_H
#define FILENAVIGATOR_H

#include "IncFreeTrack.h"
#include "freetrackwidget.h"

class FTPushButton;
class FTLabel;
class FTList;

class FileNavigator : public FreeTrackWidget
{
    Q_OBJECT
public:
    ~FileNavigator();

public:    // STATIC SECTION
    // Open a file dialog to load a map
    static QString openMap(QString default_map = "" );
    // Open a file dialog to load a calibration file
    static QString openCal();
    // Open a file dialog to load a track
    static QString openTrack(QString caption, QString default_track = "" );
    // Open a file dialog to save a track
    static QString saveTrack(QString caption, QString default_track = "" );
    // Get default path
    static QString default_path();
    // Get map cache path
    static QString map_cache_path();

signals:
    // Emitted when a file is selected
    void fileSelected();
    // Or when the user select "cancel"
    void fileRejected();

private slots:
    // Click on an item in the view
    void listSelect(const QString&);
    // When user edits the filename
    void filenameChanged(QString);
//    void filenameChanged(int,int);
    // Go up...
    void goupSlot();
    // Verify that filename is not duplicated/overwrite
    void checkAccept();

private:
    // Private constructor to prevent useage outside static members.
    explicit FileNavigator(bool, const QString&, const QString&, const QStringList& );

    // Return currently selected filename
    QString getFilename();

    // All the widgets of the dialog box
    FTList* list;
    FTPushButton* goup;
    FTPushButton* select;
    FTPushButton* cancel;
    QLineEdit* edit_filename;
    FTLabel* folder;
    FTLabel* caption;

    // The directory data
    QDir path;

    // If true, we are in "open" mode, otherwise we are in "save" mode
    bool openMode;

    // The filename
//    QString filename;

    QLayout* createHorizontal();
    QLayout* createVertical();

    void populateList();
};

#endif // FILENAVIGATOR_H
